package com.smart.community.community.service;

import com.smart.community.commons.base.BaseEntity;
import com.smart.community.commons.result.PageResult;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 社区服务管理Service接口
 * 提供公告管理、活动管理、便民服务等相关的业务操作
 * 
 * @author Wu.Liang
 * @since 2024-12-19
 * @version 1.0.0
 */
public interface ICommunityServiceManager {
    
    // ========================= 公告管理 =========================
    
    /**
     * 发布社区公告
     * 
     * @param notice 公告信息
     * @return 公告ID
     */
    Long publishNotice(CommunityNotice notice);
    
    /**
     * 分页查询社区公告
     * 
     * @param current     当前页
     * @param size        每页大小
     * @param communityId 社区ID
     * @param noticeType  公告类型
     * @param status      状态
     * @return 分页结果
     */
    PageResult<CommunityNotice> pageNotices(Integer current, Integer size,
                                           Long communityId, String noticeType, Integer status);
    
    /**
     * 根据社区ID查询有效公告
     * 
     * @param communityId 社区ID
     * @return 公告列表
     */
    List<CommunityNotice> getActiveNoticesByCommunityId(Long communityId);
    
    /**
     * 更新公告状态
     * 
     * @param noticeId 公告ID
     * @param status   状态
     * @return 是否更新成功
     */
    boolean updateNoticeStatus(Long noticeId, Integer status);
    
    // ========================= 活动管理 =========================
    
    /**
     * 创建社区活动
     * 
     * @param activity 活动信息
     * @return 活动ID
     */
    Long createActivity(CommunityActivity activity);
    
    /**
     * 分页查询社区活动
     * 
     * @param current      当前页
     * @param size         每页大小
     * @param communityId  社区ID
     * @param activityType 活动类型
     * @param status       状态
     * @return 分页结果
     */
    PageResult<CommunityActivity> pageActivities(Integer current, Integer size,
                                                Long communityId, String activityType, Integer status);
    
    /**
     * 报名参加活动
     * 
     * @param activityId 活动ID
     * @param userId     用户ID
     * @return 是否报名成功
     */
    boolean joinActivity(Long activityId, Long userId);
    
    /**
     * 取消活动报名
     * 
     * @param activityId 活动ID
     * @param userId     用户ID
     * @return 是否取消成功
     */
    boolean cancelActivityJoin(Long activityId, Long userId);
    
    /**
     * 查询用户参与的活动
     * 
     * @param userId 用户ID
     * @return 活动列表
     */
    List<CommunityActivity> getUserActivities(Long userId);
    
    // ========================= 便民服务管理 =========================
    
    /**
     * 添加便民服务
     * 
     * @param service 服务信息
     * @return 服务ID
     */
    Long addCommunityService(CommunityService service);
    
    /**
     * 分页查询便民服务
     * 
     * @param current     当前页
     * @param size        每页大小
     * @param communityId 社区ID
     * @param serviceType 服务类型
     * @return 分页结果
     */
    PageResult<CommunityService> pageServices(Integer current, Integer size,
                                             Long communityId, String serviceType);
    
    /**
     * 创建服务订单
     * 
     * @param serviceOrder 服务订单
     * @return 订单ID
     */
    Long createServiceOrder(ServiceOrder serviceOrder);
    
    /**
     * 分页查询服务订单
     * 
     * @param current 当前页
     * @param size    每页大小
     * @param userId  用户ID
     * @param status  订单状态
     * @return 分页结果
     */
    PageResult<ServiceOrder> pageServiceOrders(Integer current, Integer size,
                                              Long userId, Integer status);
    
    /**
     * 更新订单状态
     * 
     * @param orderId 订单ID
     * @param status  状态
     * @return 是否更新成功
     */
    boolean updateOrderStatus(Long orderId, Integer status);
    
    // ========================= 社区团购管理 =========================
    
    /**
     * 发起团购活动
     * 
     * @param groupBuy 团购信息
     * @return 团购ID
     */
    Long createGroupBuy(GroupBuy groupBuy);
    
    /**
     * 分页查询团购活动
     * 
     * @param current     当前页
     * @param size        每页大小
     * @param communityId 社区ID
     * @param status      状态
     * @return 分页结果
     */
    PageResult<GroupBuy> pageGroupBuys(Integer current, Integer size,
                                      Long communityId, Integer status);
    
    /**
     * 参与团购
     * 
     * @param groupBuyId 团购ID
     * @param userId     用户ID
     * @param quantity   数量
     * @return 是否参与成功
     */
    boolean joinGroupBuy(Long groupBuyId, Long userId, Integer quantity);
    
    // ========================= 统计分析 =========================
    
    /**
     * 获取社区服务统计信息
     * 
     * @param communityId 社区ID
     * @return 统计信息
     */
    ServiceStatistics getServiceStatistics(Long communityId);
    
    // ========================= 内部类定义 =========================
    
    /**
     * 社区公告
     */
    class CommunityNotice extends BaseEntity {
        private Long communityId;
        private String noticeTitle;
        private String noticeContent;
        private String noticeType;
        private Integer status;
        private Integer priority;
        private LocalDateTime publishTime;
        private String attachments;
        
        // getter/setter methods
        public Long getCommunityId() { return communityId; }
        public void setCommunityId(Long communityId) { this.communityId = communityId; }
        
        public String getNoticeTitle() { return noticeTitle; }
        public void setNoticeTitle(String noticeTitle) { this.noticeTitle = noticeTitle; }
        
        public String getNoticeContent() { return noticeContent; }
        public void setNoticeContent(String noticeContent) { this.noticeContent = noticeContent; }
        
        public String getNoticeType() { return noticeType; }
        public void setNoticeType(String noticeType) { this.noticeType = noticeType; }
        
        public Integer getStatus() { return status; }
        public void setStatus(Integer status) { this.status = status; }
        
        public Integer getPriority() { return priority; }
        public void setPriority(Integer priority) { this.priority = priority; }
        
        public LocalDateTime getPublishTime() { return publishTime; }
        public void setPublishTime(LocalDateTime publishTime) { this.publishTime = publishTime; }
        
        public String getAttachments() { return attachments; }
        public void setAttachments(String attachments) { this.attachments = attachments; }
    }
    
    /**
     * 社区活动
     */
    class CommunityActivity extends BaseEntity {
        private Long communityId;
        private String activityTitle;
        private String activityContent;
        private String activityType;
        private LocalDateTime startTime;
        private LocalDateTime endTime;
        private String location;
        private Integer maxParticipants;
        private Integer currentParticipants;
        private Long organizerId;
        private String contactInfo;
        private Integer status;
        
        // getter/setter methods
        public Long getCommunityId() { return communityId; }
        public void setCommunityId(Long communityId) { this.communityId = communityId; }
        
        public String getActivityTitle() { return activityTitle; }
        public void setActivityTitle(String activityTitle) { this.activityTitle = activityTitle; }
        
        public String getActivityContent() { return activityContent; }
        public void setActivityContent(String activityContent) { this.activityContent = activityContent; }
        
        public String getActivityType() { return activityType; }
        public void setActivityType(String activityType) { this.activityType = activityType; }
        
        public LocalDateTime getStartTime() { return startTime; }
        public void setStartTime(LocalDateTime startTime) { this.startTime = startTime; }
        
        public LocalDateTime getEndTime() { return endTime; }
        public void setEndTime(LocalDateTime endTime) { this.endTime = endTime; }
        
        public String getLocation() { return location; }
        public void setLocation(String location) { this.location = location; }
        
        public Integer getMaxParticipants() { return maxParticipants; }
        public void setMaxParticipants(Integer maxParticipants) { this.maxParticipants = maxParticipants; }
        
        public Integer getCurrentParticipants() { return currentParticipants; }
        public void setCurrentParticipants(Integer currentParticipants) { this.currentParticipants = currentParticipants; }
        
        public Long getOrganizerId() { return organizerId; }
        public void setOrganizerId(Long organizerId) { this.organizerId = organizerId; }
        
        public String getContactInfo() { return contactInfo; }
        public void setContactInfo(String contactInfo) { this.contactInfo = contactInfo; }
        
        public Integer getStatus() { return status; }
        public void setStatus(Integer status) { this.status = status; }
    }
    
    /**
     * 便民服务
     */
    class CommunityService extends BaseEntity {
        private Long communityId;
        private String serviceName;
        private String serviceDescription;
        private String serviceType;
        private Long providerId;
        private String contactInfo;
        private Integer status;
        
        // getter/setter methods
        public Long getCommunityId() { return communityId; }
        public void setCommunityId(Long communityId) { this.communityId = communityId; }
        
        public String getServiceName() { return serviceName; }
        public void setServiceName(String serviceName) { this.serviceName = serviceName; }
        
        public String getServiceDescription() { return serviceDescription; }
        public void setServiceDescription(String serviceDescription) { this.serviceDescription = serviceDescription; }
        
        public String getServiceType() { return serviceType; }
        public void setServiceType(String serviceType) { this.serviceType = serviceType; }
        
        public Long getProviderId() { return providerId; }
        public void setProviderId(Long providerId) { this.providerId = providerId; }
        
        public String getContactInfo() { return contactInfo; }
        public void setContactInfo(String contactInfo) { this.contactInfo = contactInfo; }
        
        public Integer getStatus() { return status; }
        public void setStatus(Integer status) { this.status = status; }
    }
    
    /**
     * 服务订单
     */
    class ServiceOrder extends BaseEntity {
        private Long serviceId;
        private Long userId;
        private String orderNo;
        private String orderDescription;
        private LocalDateTime appointmentTime;
        private Integer status;
        private String feedback;
        
        // getter/setter methods
        public Long getServiceId() { return serviceId; }
        public void setServiceId(Long serviceId) { this.serviceId = serviceId; }
        
        public Long getUserId() { return userId; }
        public void setUserId(Long userId) { this.userId = userId; }
        
        public String getOrderNo() { return orderNo; }
        public void setOrderNo(String orderNo) { this.orderNo = orderNo; }
        
        public String getOrderDescription() { return orderDescription; }
        public void setOrderDescription(String orderDescription) { this.orderDescription = orderDescription; }
        
        public LocalDateTime getAppointmentTime() { return appointmentTime; }
        public void setAppointmentTime(LocalDateTime appointmentTime) { this.appointmentTime = appointmentTime; }
        
        public Integer getStatus() { return status; }
        public void setStatus(Integer status) { this.status = status; }
        
        public String getFeedback() { return feedback; }
        public void setFeedback(String feedback) { this.feedback = feedback; }
    }
    
    /**
     * 团购活动
     */
    class GroupBuy extends BaseEntity {
        private Long communityId;
        private String groupBuyTitle;
        private String productName;
        private String productDescription;
        private Integer minQuantity;
        private Integer currentQuantity;
        private LocalDateTime expireTime;
        private Integer status;
        
        // getter/setter methods
        public Long getCommunityId() { return communityId; }
        public void setCommunityId(Long communityId) { this.communityId = communityId; }
        
        public String getGroupBuyTitle() { return groupBuyTitle; }
        public void setGroupBuyTitle(String groupBuyTitle) { this.groupBuyTitle = groupBuyTitle; }
        
        public String getProductName() { return productName; }
        public void setProductName(String productName) { this.productName = productName; }
        
        public String getProductDescription() { return productDescription; }
        public void setProductDescription(String productDescription) { this.productDescription = productDescription; }
        
        public Integer getMinQuantity() { return minQuantity; }
        public void setMinQuantity(Integer minQuantity) { this.minQuantity = minQuantity; }
        
        public Integer getCurrentQuantity() { return currentQuantity; }
        public void setCurrentQuantity(Integer currentQuantity) { this.currentQuantity = currentQuantity; }
        
        public LocalDateTime getExpireTime() { return expireTime; }
        public void setExpireTime(LocalDateTime expireTime) { this.expireTime = expireTime; }
        
        public Integer getStatus() { return status; }
        public void setStatus(Integer status) { this.status = status; }
    }
    
    /**
     * 服务统计
     */
    class ServiceStatistics {
        private Integer totalNotices;
        private Integer activeNotices;
        private Integer totalActivities;
        private Integer upcomingActivities;
        private Integer totalServices;
        private Integer activeServices;
        private Integer totalOrders;
        private Integer completedOrders;
        private Integer totalGroupBuys;
        private Integer activeGroupBuys;
        
        // getter/setter methods
        public Integer getTotalNotices() { return totalNotices; }
        public void setTotalNotices(Integer totalNotices) { this.totalNotices = totalNotices; }
        
        public Integer getActiveNotices() { return activeNotices; }
        public void setActiveNotices(Integer activeNotices) { this.activeNotices = activeNotices; }
        
        public Integer getTotalActivities() { return totalActivities; }
        public void setTotalActivities(Integer totalActivities) { this.totalActivities = totalActivities; }
        
        public Integer getUpcomingActivities() { return upcomingActivities; }
        public void setUpcomingActivities(Integer upcomingActivities) { this.upcomingActivities = upcomingActivities; }
        
        public Integer getTotalServices() { return totalServices; }
        public void setTotalServices(Integer totalServices) { this.totalServices = totalServices; }
        
        public Integer getActiveServices() { return activeServices; }
        public void setActiveServices(Integer activeServices) { this.activeServices = activeServices; }
        
        public Integer getTotalOrders() { return totalOrders; }
        public void setTotalOrders(Integer totalOrders) { this.totalOrders = totalOrders; }
        
        public Integer getCompletedOrders() { return completedOrders; }
        public void setCompletedOrders(Integer completedOrders) { this.completedOrders = completedOrders; }
        
        public Integer getTotalGroupBuys() { return totalGroupBuys; }
        public void setTotalGroupBuys(Integer totalGroupBuys) { this.totalGroupBuys = totalGroupBuys; }
        
        public Integer getActiveGroupBuys() { return activeGroupBuys; }
        public void setActiveGroupBuys(Integer activeGroupBuys) { this.activeGroupBuys = activeGroupBuys; }
    }
}
